﻿using System.Collections.Generic;
using System.Linq;
using Application.DTO;
using Infrastructure.DC;

namespace Application.Task
{
    public class RetrieveAllCustomers
    {
        private ICustomersDao _customersDao;
        public RetrieveAllCustomersResult Result { get; private set; }
        public RetrieveAllCustomers():this(new CustomersDao())
        {
            
        }
        public RetrieveAllCustomers(ICustomersDao customerDao)
        {
            _customersDao = customerDao;
            Result = new RetrieveAllCustomersResult();
        }
        public void Execute()
        {
            IEnumerable<DomainModel.PDC.Customer> res = _customersDao.RetrieveAll();
int resCount = res.ToList().Count;
            var dto = new CustomerInfoMapper().From(res);

            
            Result.TotalRecords = resCount;
            Result.Add(dto);

        }
    }
}